package com.moxc.learn_springai_01.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.moxc.learn_springai_01.entity.po.ChatHistory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChatHistoryMapper extends BaseMapper<ChatHistory>{
    /**
     * 删除一条聊天记录
     * @param type
     * @param chatId
     */
    @Delete("DELETE FROM chat_history WHERE type = #{type} AND chat_id = #{chatId}")
    void delete(@Param("type") String type, @Param("chatId") String chatId);

    /**
     * 根据type获取聊天记录的chatIds
     * @param type
     * @return
     */
    @Select("SELECT chat_id FROM chat_history WHERE type = #{type}")
    List<String> selectChatIdsByType(String type);

}
